
/**
 * 详情对话框
 */
var InfoDlg = {
    data: {
        pid: "",
        pcodeName: ""
    }
};

layui.use(['layer', 'form', 'admin', 'ax'], function () {

    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    $('#pcodeName').click(function () {
        var formName = encodeURIComponent('parent.InfoDlg.data.pcodeName');
        var formId = encodeURIComponent('parent.InfoDlg.data.pid');
        var treeUrl = encodeURIComponent('/system/menu/selectMenuTreeList');

        layer.open({
            type: 2,
            title: '父级菜单选择',
            area: ['90%', '90%'],
            content: '/system/commonTree?formName='+formName+'&formId='+formId+'&treeUrl='+treeUrl+'',
            end: function () {
                $("#pid").val(InfoDlg.data.pid);
                $("#pcodeName").val(InfoDlg.data.pcodeName);
            }
        });

    });

    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Lu.ctxPath + '/system/menu/add', function (data) {
            admin.putTempData('msg', '添加成功!');
            admin.putTempData('formOk', true);
            admin.closeThisDialog();
        }, function (data) {
            Lu.error('添加失败!' + data.responseJSON.message);
        });
        ajax.set(data.field);
        ajax.start();
        return false;
    });

})